﻿<?php
require_once('../../../config.php');
 require_once($CFG->libdir . '/adminlib.php');
 require_once($CFG->dirroot . '/local/myplugin/lib.php');
require_once($CFG->dirroot . "/local/myplugin/forms.php");


global $DB;
$option=array();

/* Ket noi den file javascript - module.js */
$PAGE->requires->js_init_call('M.local_myplugin');	
$cssdir =  $CFG->wwwroot.'/local/myplugin/css/mycss.css';
echo '<link rel="stylesheet" href="'.$cssdir.'" type="text/css" media="screen" />';
echo '<script src="../module.js"></script>';
/* Chuan bi trang web can hien thi */	
$url = new moodle_url($CFG->wwwroot.'local/myplugin/curriculum/program.php');
$PAGE->set_url($url);
$PAGE->set_title('Add Academic Program');
$PAGE->set_heading('Add Academic Program');
$PAGE->set_pagelayout('standard');

//Them thanh menu ngang ung voi trang trong duong link
navigation_node::override_active_url(new moodle_url($CFG->wwwroot.'/local/myplugin/curriculum/program.php', array('param'=>'value')));

echo $OUTPUT->header();

/* Viet doan code cua ban o day */

//add tab vào trang
$mylib = new curriculum_management();

$mform= new form_program();
$mform->display();
//bat su kien nhan nu cancel
if ($mform->is_cancelled()) {

echo 'hủy thao tác';

}

//kiem tra neu dc submitted thì làm gì
if ($fromform = $mform->get_data()) 
{
	$option['program_name']=$fromform->txtten;
	$option['program_level']=$fromform->txtlevel;
	$option['program_type']=$fromform->txttype;
	$option['program_description']=$fromform->txtdesc;
	$them=$mylib->add_program($option);
	if($them)
	{
		echo "<script  type='text/javascript'>success_mess('Academic Program Is Added Successfully!');</script>";
	}
	else
	{
		echo "<script  type='text/javascript'>success_mess('Academic Program Is Added Successfully!');</script>";
	}
}
echo "<script  type='text/javascript'>load_program_table();</script>";

/*------Ket thuc doan code cua ban-------*/

echo $OUTPUT->footer();

